<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<HEAD>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<title>选择列表</title>
		<!--js库及样式-->
		<script LANGUAGE="javascript" src="../script/common.js" type="text/javascript"></script>
		<!--动态js-->
		<script language="javascript" type="text/javascript">
	   		var org = Common.cOrg()
	   		
			var qt = {}
			var b=false;
			function load(){
		   $("acclevel").value="%"+getPara("acclevel")+"%";
			var r=getPara("id");
			   	$("mainform").locationId.value =r;
			   	
				DWR.call("giftStorageService.getLocationAllParentsTwo",r,function(v){
				 	$("mainform").orgLocation.value = v;
				 	Common.initSql(mainform.giftType,"gift_info_add_giftType",{},"0","1","全部");
					Common.initSql(mainform.subType,"gift_info_add_subType",{},"0","1","全部");
				    createTable();
			 	});	
			}
			var subType;
			function changes(s){
				if(s){
					Common.initSql($("mainform").subType,"gift_info_add_subTypeId",{subTypeId:s},"0","1","全部");
					subType = s;
				}else{
					Common.initSql(mainform.subType,"gift_info_add_subType",{},"0","1","全部");
				} 
			}
			//商品小类及联商品大类
			function subchanges(s){
			    if(s){
			    
			 
					DWR.call("giftStorageService.getParentTypeId",s,function(v){
						$("giftType").value=v.id;	
					});
				}else if(!s && subType){
					subType = null;
				}else{
					Common.initSql(mainform.giftType,"gift_info_add_giftType",{},"0","1","全部");
				}  
			}
			//设置表格数据列
			function createTable(){
				var columns = [];
				columns[0]={type:"radio"}
				
				if(b){
						qt = new QueryTable("gifconvert_list_query_true","mainform","datalist",columns);
				}else{
						qt = new QueryTable("gifconvert_list_query_false","mainform","datalist",columns);
				}
			}
			//显示、刷新表格
			function showData(){
				DWR.call("giftStorageService.getJb",$("subType").value,function(v){
		       		//createTable(v);
					b=v;
					qt.showTable();			//qt为全局的QueryTable对象
				});		
			}
			function getBackValue() {
				var obj = qt.getRadioValue(true);
				var v = {id : obj[0],
					name : obj[1]
				}
				return v;
			}
	
			function onSave() {
				var v = getBackValue();
				dialogBackValue(v);
			}
		</script>
	</HEAD>
<BODY class="body" onload="load()">
	<div id="listview">	
		<!--查询条件form-->
		<div class="form">
			<form id="mainform" name="mainform">
				<input type="hidden" name="orgLocation">
				<input type="hidden" name="locationId">
				<input type="hidden" name="acclevel">
				<table cellSpacing=0 cellPadding=4 width="100%" border=0>
					<tr>
						<td><label for="giftType">商品大类&nbsp;</label> <select name="giftType" onchange="changes()"></select></td>
						<td><label for="subType">商品子类&nbsp;</label> <select name="subType" onchange="subchanges()"></select></td>
						<td><button type="button" onclick="showData()">查 询</button></td>
					</tr>
				</table>
			</form>
		</div>
		<div id="datalist"></div>
	</div>
</BODY>
</HTML>